# Spring Boot应用配置
spring:
  application:
    name: ${tableName?lower_case}
  
  # 数据源配置
  datasource:
    url: jdbc:mysql://localhost:3306/${tableName?lower_case}_db?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver

  <#if enableRedis>
  cache:
    type: redis
  redis:
    host: localhost
    port: 6379
    password:
    timeout: 2000
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 0
        max-wait: 5000
  </#if>

# 服务器配置
server:
  port: 8080
  servlet:
    context-path: /
    encoding:
      charset: UTF-8
      enabled: true
      force: true

# MyBatis-Plus配置
mybatis-plus:
  configuration:
    # 开启驼峰命名转换
    map-underscore-to-camel-case: true
    # 开启SQL日志
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  global-config:
    db-config:
      # 主键类型
      id-type: auto
      # 逻辑删除字段
      logic-delete-field: deleted
      logic-delete-value: 1
      logic-not-delete-value: 0
  # Mapper XML文件位置
  mapper-locations: classpath*:/mapper/**/*.xml

# Swagger文档配置
springdoc:
  api-docs:
    enabled: true
    path: /v3/api-docs
  swagger-ui:
    enabled: true
    path: /swagger-ui.html
    tags-sorter: alpha
    operations-sorter: alpha

<#if enableSecurity>
app:
  security:
    tenant-header: ${securityTenantHeader}
    token-header: ${securityTokenHeader}
    token-prefix: '${securityTokenPrefix}'
    jwt:
      secret: ${jwtSecret}
      expiration-seconds: ${jwtExpirationSeconds}
      refresh-expiration-seconds: ${jwtRefreshExpirationSeconds}
    tenants:
      - tenant-id: ${securityDefaultTenant}
        users:
          - username: ${securityDefaultUsername}
            password: ${securityDefaultPassword}
            roles:
              - ${securityRole}
</#if>

# 日志配置
logging:
  level:
    [=packageName]: DEBUG
    org.springframework.web: INFO
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
  file:
    name: logs/[=tableName?lower_case].log

# 管理端点
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics
  endpoint:
    health:
      show-details: when_authorized
